using MeetingRoomBooking.Application.Common.Middlewares;
using MeetingRoomBooking.Infrastructure.Data;

var builder = WebApplication.CreateBuilder(args);


builder.AddApplicationServices();
builder.AddInfrastructureServices();
builder.AddAPIServices();

var app = builder.Build();
app.UseCors("AllowAll");
if (app.Environment.IsDevelopment())
{
    await app.InitialiseDatabaseAsync();
    app.UseSwagger();
    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "Meeting Room Booking API Vs1");
        app.MapGet("/", () => Results.Redirect("/swagger"));
    });
}
// Configure the HTTP request pipeline.

app.UseAuthentication();
app.UseAuthorization();
app.UseExceptionHandling();
app.MapControllers();

app.Run();
